package com.lifeverse.entity;

import com.lifeverse.entity.enums.PatternType;
import com.lifeverse.entity.enums.PatternStatus;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 行为模式实体
 * 用于存储生命体的行为模式数据
 */
@Entity
@Table(name = "behavior_patterns")
@Data
@EqualsAndHashCode(callSuper = true)
public class BehaviorPattern extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 关联的生命体ID
     */
    @Column(name = "life_entity_id", nullable = false)
    private Long lifeEntityId;

    /**
     * 模式类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "pattern_type", nullable = false)
    private PatternType patternType;

    /**
     * 模式名称
     */
    @Column(name = "pattern_name", nullable = false, length = 100)
    private String patternName;

    /**
     * 模式描述
     */
    @Column(name = "description", length = 500)
    private String description;

    /**
     * 模式特征向量（JSON格式存储）
     */
    @Column(name = "feature_vector", columnDefinition = "TEXT")
    private String featureVector;

    /**
     * 模式置信度 (0.0 - 1.0)
     */
    @Column(name = "confidence_score", nullable = false)
    private Double confidenceScore;

    /**
     * 模式频率
     */
    @Column(name = "frequency", nullable = false)
    private Integer frequency;

    /**
     * 模式状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false)
    private PatternStatus status;

    /**
     * 首次检测时间
     */
    @Column(name = "first_detected_at", nullable = false)
    private LocalDateTime firstDetectedAt;

    /**
     * 最后检测时间
     */
    @Column(name = "last_detected_at", nullable = false)
    private LocalDateTime lastDetectedAt;

    /**
     * 模式持续时间（分钟）
     */
    @Column(name = "duration_minutes")
    private Integer durationMinutes;

    /**
     * 相关性分数（与其他模式的关联度）
     */
    @Column(name = "correlation_score")
    private Double correlationScore;

    /**
     * 异常分数（0.0表示正常，1.0表示高度异常）
     */
    @Column(name = "anomaly_score")
    private Double anomalyScore;

    /**
     * 预测准确率
     */
    @Column(name = "prediction_accuracy")
    private Double predictionAccuracy;

    /**
     * 扩展属性（JSON格式）
     */
    @Column(name = "metadata", columnDefinition = "TEXT")
    private String metadata;
}